#ifndef CZHPACK_H
#define CZHPACK_H

#include <stdint.h>
#include <stdbool.h>

#define CZHPACK_SIGNATURE                   "CZHPACK"
#define CZHPACK_NAME_SIZE                   7
#define CZHPACK_ATTRIBUTE_DIRECTORY         0x80

struct czhpack_item
{
    uint8_t name[CZHPACK_NAME_SIZE];
    uint8_t attribute;//0x00:file,0x80:directory
    uint16_t offset;
    uint16_t length;
};

//basic
struct czhpack_item * czhpack_get(const unsigned char *pack,const unsigned char *path);
void czhpack_list(const unsigned char *pack,const unsigned char *path,void (*visit)(struct czhpack_item *));

//advanced
uint8_t czhpack_get_uint8(const unsigned char *pack,const unsigned char *path);
uint16_t czhpack_get_uint16(const unsigned char *pack,const unsigned char *path);
uint32_t czhpack_get_uint32(const unsigned char *pack,const unsigned char *path);
int8_t czhpack_get_int8(const unsigned char *pack,const unsigned char *path);
int16_t czhpack_get_int16(const unsigned char *pack,const unsigned char *path);
int32_t czhpack_get_int32(const unsigned char *pack,const unsigned char *path);
void * czhpack_get_pointer(const unsigned char *pack,const unsigned char *path);

#endif
